<template>
  <div class="index">
    <div class="index-img">
      <div class="img-content">
        <h2>欢迎来到BUO宠物生活馆</h2>
        <p>
          我们是一个专注于所有猫的宠物生活馆，致力于为所有猫提供最优质的服务和产品。
        </p>
        <el-button
          type="primary"
          size="large"
          round
          class="index-btn"
          @click="showAbout = true"
          >了解更多</el-button
        >
        <about-us v-if="showAbout" @close="showAbout = false" />
      </div>
    </div>
    <el-divider />
    <div class="cat-section">
      <h1 class="cat-title">布偶猫品种介绍</h1>
      <div class="card-list">
        <div class="card" v-for="card in cards" :key="card.id">
          <img :src="card.img" :alt="card.title" class="card-img" />
          <div class="card-content">
            <h3 class="card-title">{{ card.title }}</h3>
            <p class="card-desc">{{ card.description }}</p>
          </div>
        </div>
      </div>
    </div>
    <div class="comment-section">
      <h1 class="comment-title">客户评价与互动</h1>
      <div class="comment-list">
        <div
          class="comment-card"
          v-for="comment in comments"
          :key="comment.comment"
        >
          <img v-if="comment.img" :src="comment.img" class="card-img" />
          <p class="card-desc">{{ comment.comment }}</p>
          <p class="comment-name">-{{ comment.name }}</p>
        </div>
      </div>
      <div class="story-form">
        <h1 class="story-title">分享您的宠物故事</h1>
        <div class="story-input-row">
          <el-input
            v-model="input"
            type="textarea"
            :rows="4"
            class="story-textarea"
            placeholder="我们很乐意听到您的反馈和故事！"
          ></el-input>
          <el-button type="primary" class="story-btn" @click="submitFeedback">
            提交反馈
            <i class="el-icon-s-promotion" style="margin-left: 6px"></i>
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import aboutUs from "../components/aboutUs.vue";
const input = ref("");
const showAbout = ref(false);

const cards = [
  {
    title: "海双布偶",
    description:
      "海豹双色布偶猫，面部呈倒V形白色区域，耳朵、尾巴及四肢末端为深棕色，身体为浅米色。毛色对比鲜明，眼睛湛蓝如宝石，性格温顺沉稳，体型较大且肌肉发达，是布偶猫中最经典的毛色类型。",
    img: new URL("../assets/image/cat1.png", import.meta.url).href,
    id: 1,
  },
  {
    title: "蓝双布偶",
    description:
      "蓝色双色布偶猫，面部白色区域对称，耳朵、尾巴及四肢末端为蓝灰色，身体呈银白色。毛色柔和清冷，搭配蓝宝石色眼睛，气质优雅高贵，性格活泼亲人，适应力强，适合公寓生活。",
    img: new URL("../assets/image/cat2.png", import.meta.url).href,
    id: 2,
  },
  {
    title: "巧克力双布偶",
    description:
      "巧克力双色布偶猫，面部白色区域与暖棕色重点色形成对比，耳朵、尾巴为深巧克力色，身体为浅奶油色。毛色温暖柔和，性格温顺安静，叫声轻柔，适合与儿童或老人共同生活。",
    img: new URL("../assets/image/cat3.png", import.meta.url).href,
    id: 3,
  },
  {
    title: "丁香双布偶",
    description:
      "丁香双色布偶猫，面部白色区域与淡紫色重点色交织，耳朵、尾巴为浅灰色，身体呈冷调银白色。毛色清冷高级，性格独立安静，喜欢安静环境，适合独居或小家庭饲养。",
    img: new URL("../assets/image/cat4.png", import.meta.url).href,
    id: 4,
  },
  {
    title: "火焰双布偶",
    description:
      "火焰双色布偶猫，面部白色区域与橙红色重点色形成鲜明对比，耳朵、尾巴为火焰般鲜艳的橙红色，身体为浅米色。毛色热情夺目，性格活泼好动，好奇心强，需要充足互动空间。",
    img: new URL("../assets/image/cat5.jpg", import.meta.url).href,
    id: 5,
  },
  {
    title: "玳瑁双布偶",
    description:
      "玳瑁双色布偶猫，面部白色区域与玳瑁色斑块交织，身体散布不规则红色、黑色及白色色块，每只猫的花纹独一无二。性格聪明独立，认主意识强，适合有养猫经验的主人。",
    img: new URL("../assets/image/cat6.jpeg", import.meta.url).href,
    id: 6,
  },
  {
    title: "海豹重点色布偶",
    description:
      "海豹重点色布偶猫，面部、耳朵、尾巴及四肢为深棕色，身体为浅米色，无白色区域。毛色与暹罗猫相似但体型更大、毛更长，性格安静温顺，喜欢陪伴主人，适合喜欢传统重点色外观的饲主。",
    img: new URL("../assets/image/cat7.jpg", import.meta.url).href,
    id: 7,
  },
  {
    title: "蓝重点色布偶",
    description:
      "蓝重点色布偶猫，面部、耳朵、尾巴及四肢为蓝灰色，身体为银白色，无白色区域。毛色清冷柔和，性格沉稳亲人，适应力强，是重点色布偶中较受欢迎的毛色类型。",
    img: new URL("../assets/image/cat8.jpg", import.meta.url).href,
    id: 8,
  },
];

const comments = [
  {
    comment:
      "BUO宠物生活馆的服务真是太棒了！我的小狗在这里找到了最适合它的家，工作人员非常专业和有爱心。",
    img: new URL("../assets/image/people1.jpg", import.meta.url).href,
    name: "张女士",
  },
  {
    comment:
      "在这里购买的猫咪非常健康活泼，售后服务也做得很好，强烈推荐给所有爱宠人士！",
    img: new URL("../assets/image/people2.jpg", import.meta.url).href,
    name: "王先生",
  },
  {
    comment:
      "BUO的宠物用品种类齐全，质量上乘，每次来都能找到我需要的东西，非常方便。",
    img: new URL("../assets/image/people3.jpg", import.meta.url).href,
    name: "李先生",
  },
];

const submitFeedback = () => {
  // console.log("用户反馈:", input.value);
  alert("感谢您的反馈，我们会认真对待每一条建议!");
  input.value = ""; // 清空输入框
};
</script>

<style lang="less" scoped>
.index {
  width: 100%;
  min-height: 100vh;
  background: #f5f6fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 0;
}
.index-img {
  background-image: url("../assets/image/index-img.jpeg");
  width: 100%;
  height: 800px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  padding-bottom: 20px;
}

.img-content {
  text-align: left;
  position: relative;
  z-index: 2;
  max-width: 800px;
  padding: 0 0 0 30px;
  margin-left: 30px;
}

.img-content h2 {
  color: rgba(135, 206, 235, 0.9);
  font-size: 52px;
  margin-bottom: 20px;
}

.img-content p {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 30px;
}

.index-btn {
  size: 40px;
  font-size: 16px;
}

/* 响应式设计调整 */
@media (max-width: 768px) {
  .img-content {
    padding: 0 0 0 30px;
    margin-left: 30px;
  }
  .img-content h2 {
    font-size: 28px;
  }
  .img-content p {
    font-size: 16px;
  }
  .index-btn {
    font-size: 14px;
    padding: 10px 20px;
  }
}

@media (max-width: 480px) {
  .img-content {
    padding: 0 0 0 20px;
    margin-left: 20px;
  }
  .img-content h2 {
    font-size: 24px;
  }
  .img-content p {
    font-size: 14px;
  }
  .index-btn {
    font-size: 12px;
    padding: 8px 16px;
  }
}
.cat-section {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto 48px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cat-title {
  font-size: 2.4rem;
  font-weight: 700;
  color: #8d26e6;
  margin-bottom: 36px;
  margin-top: 0;
  text-align: center;
  letter-spacing: 2px;
}

.card-list {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  justify-items: center;
  align-items: stretch;
  margin-bottom: 0;
}

.card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(140, 38, 230, 0.08), 0 1.5px 6px #e0e0e0;
  width: 100%;
  max-width: 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  overflow: hidden;
  &:hover {
    box-shadow: 0 8px 32px rgba(140, 38, 230, 0.16), 0 2px 8px #d1c4e9;
    transform: translateY(-4px) scale(1.03);
  }
  .card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 18px 18px 0 0;
    background: #f6edff;
    display: block;
  }
  .card-content {
    padding: 18px 20px 0 20px;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .card-title {
    font-size: 20px;
    font-weight: 700;
    color: #222;
    margin: 0 0 10px 0;
    letter-spacing: 1px;
    line-height: 1.3;
  }
  .card-desc {
    font-size: 15px;
    color: #444;
    margin: 0 0 12px 0;
    line-height: 1.7;
    min-height: 48px;
    flex: 1;
  }
}

.comment-section {
  width: 100%;
  background: #f6edff;
  padding: 48px 0 60px 0;
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.comment-title {
  font-size: 2rem;
  font-weight: 700;
  color: #8d26e6;
  margin-bottom: 36px;
  text-align: center;
  letter-spacing: 2px;
}

.comment-list {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  justify-items: center;
  align-items: stretch;
  margin-bottom: 32px;
}

.comment-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(140, 38, 230, 0.08), 0 1.5px 6px #e0e0e0;
  width: 340px;
  padding: 24px 20px 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  .card-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    background: #f6edff;
  }
  .card-desc {
    font-size: 15px;
    color: #444;
    text-align: center;
    line-height: 1.7;
    margin: 0 0 8px 0;
    min-height: 60px;
  }
  .comment-name {
    font-size: 14px;
    color: #8d26e6;
    margin-top: 4px;
    text-align: right;
    width: 100%;
  }
}

.story-form {
  width: 100%;
  max-width: 700px;
  margin: 40px auto 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 40px 16px;
}

.story-title {
  color: #8d26e6;
  font-size: 2rm;
  font-weight: 700;
  margin-bottom: 18px;
  text-align: center;
  letter-spacing: 1px;
  padding-bottom: 15px;
}

.story-input-row {
  width: 100%;
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: center;
}

.story-textarea {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1px solid #e3d8f7;
  background: #fff;
  box-shadow: 0 1px 4px rgba(140, 38, 230, 0.04);
}

.story-btn {
  height: 48px;
  font-size: 1.1rem;
  border-radius: 24px;
  padding: 0 32px;
  margin-left: 8px;
  display: flex;
  align-items: center;
  background: linear-gradient(90deg, #a259ff 0%, #8d26e6 100%);
  border: none;
  box-shadow: 0 2px 12px rgba(140, 38, 230, 0.1);
  color: #fff;
  font-weight: 600;
  transition: background 0.2s;
}
.story-btn:hover {
  background: linear-gradient(90deg, #8d26e6 0%, #a259ff 100%);
}

@media (max-width: 1200px) {
  .cat-section {
    max-width: 1000px;
  }
  .card-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
  .comment-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}
@media (max-width: 900px) {
  .cat-section {
    max-width: 700px;
  }
  .card-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }
  .card {
    max-width: 100%;
    .card-img {
      height: 140px;
    }
  }
  .comment-list {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}
@media (max-width: 600px) {
  .cat-section {
    max-width: 98vw;
    padding: 0 2vw;
  }
  .card-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .card {
    max-width: 100%;
    .card-img {
      height: 100px;
    }
    .card-content {
      padding: 12px 8px 0 8px;
    }
  }
  .comment-card {
    width: 98vw;
    max-width: 340px;
    padding: 12px 6px 10px 6px;
  }
  .comment-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .story-form {
    max-width: 98vw;
    padding: 18px 4vw 24px 4vw;
  }
  .story-input-row {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .story-btn {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }
}
</style>
